﻿using System;
using System.IO;

namespace CNKI.Graduate.Framework.Platform
{
    /// <summary>
    /// 各种公共路径常量
    /// </summary>
    public static class Paths
    {
        private const string DataDir = "data";
        private const string ConfigDir = @"data\config";
        private const string ResourcesDir = @"data\resources";
        private const string TempDir = @"data\temp";

        /// <summary>
        /// 程序安装的主目录的路径.
        /// </summary>
        public static string AppBase = AppDomain.CurrentDomain.BaseDirectory;

        /// <summary>
        /// 程序主目录下的data目录的完整路径.
        /// </summary>
        public static string AppData = Path.Combine(AppBase, DataDir);

        /// <summary>
        /// 存放XML配置文件的目录的完整路径.
        /// </summary>
        public static string ConfigFiles = Path.Combine(AppBase, ConfigDir);

        /// <summary>
        /// 存放图片等资源文件的目录的完整路径.
        /// </summary>
        public static string ResourceFiles = Path.Combine(AppBase, ResourcesDir);

        /// <summary>
        /// 存放临时文件的目录的完整路径.
        /// </summary>
        public static string TempFiles = Path.Combine(AppBase, TempDir);
        /// <summary>
        /// 构造产品组件DLL的路径
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static string BuildModuleAssemblyPath(string fileName)
        {
            return Path.Combine(AppBase, fileName);
        }

        /// <summary>
        /// 构造data目录中<paramref name="dirName"/>指定的子目录下
        /// <paramref name="fileName"/>文件的完整路径.
        /// </summary>
        /// <param name="dirName"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static string BuildDataFilePath(string dirName, string fileName)
        {
            return Path.Combine(Path.Combine(AppData, dirName), fileName);
        }
        /// <summary>
        /// 构造data目录中的文件路径
        /// </summary>
        /// <param name="fileName">文件名</param>
        /// <returns></returns>
        public static string BuildDataFilePath(string fileName)
        {
            return Path.Combine(AppData, fileName);
        }

        /// <summary>
        /// 构造XML配置文件目录下<paramref name="fileName"/>文件的完整路径.
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static string BuildConfigFilePath(string fileName)
        {
            return Path.Combine(ConfigFiles, fileName);
        }

        /// <summary>
        /// 构造资源文件目录中文件的完整路径.
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static string BuildResourceFilePath(string fileName)
        {
            return Path.Combine(ResourceFiles, fileName);
        }

        /// <summary>
        /// 构造临时文件目录中文件的完整路径.
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static string BuildTempFilePath(string fileName)
        {
            return Path.Combine(TempFiles, fileName);
        }
    }
}
